<include file="Public:header"/>
<body class="bgf6">
	<!-- 头部 -->
    <div class="header-container bgfff">
            <div class="weui-cell ih30">
                <div class="weui-cell__hd">

                </div>
                <div class="weui-cell__bd">
                	{$shop.name}
                </div>
            </div>
    </div>
    <!-- 内容 -->
    <div class="xq_container bgfff m100vh ">
        <div class="pad10">
            <div class="inptop">
                手机号
            </div>
            <div class="inpbox">
                <input type="text" placeholder="请留下您的手机号，方便与您联系" name="tel" id="tel">
            </div>
            <div class="inptop">
                姓名
            </div>
            <div class="inpbox">
                <input type="text" placeholder="您怎么称呼" name="name" id="name">
            </div>
            <div class="inptop">
                留言信息
            </div>
            <div class="weui-cell text">
                    <div class="weui-cell__bd">
                        <textarea class="weui-textarea" id="content" placeholder="请详细描述您的意见或建议" rows="3"></textarea>
                    </div>
            </div>
        </div>
        <div class="push">
            发表留言
        </div>
    </div>

    <div class="weuilog" style="display: none;">
        <div class="weui-mask"></div>
        <div class="weui-dialog">
            <div class="weui-dialog__hd"><strong class="weui-dialog__title">提示</strong></div>
            <div class="weui-dialog__bd">信息不能为空！</div>
            <div class="weui-dialog__ft">
                <a href="javascript:;" class="weui-dialog__btn weui-dialog__btn_primary">确定</a>
            </div>
        </div>
    </div>
<include file="Public:footer"/>
<script type="text/javascript">
    $(function(){
        $('.push').click(function(){
            var name = $('#name').val().trim();
            var tel = $('#tel').val().trim();
            var content = $('#content').val().trim();
            if(name==""){
                $('.weui-dialog__bd').html('名字不能为空');
                $('.weuilog').show();
                return;
            }
            if(tel==""){
                $('.weui-dialog__bd').html('电话不能为空');
                $('.weuilog').show();
                return;
            }else if(!(/^1[3|4|5|7|8]\d{9}$/.test(tel))){
                $('.weui-dialog__bd').html('手机号格式不对');
                $('.weuilog').show();
                return;
            }
            if(content==""){
                $('.weui-dialog__bd').html('反馈内容不能为空');
                $('.weuilog').show();
                return;
            }
            $.post("{:U('Index/addMessage')}",{name:name,phone:tel,content:content},function(data){
                if(data==1){
                    $('#name').val('');
                    $('#tel').val('');
                    $('#content').val('');
                    $('.weui-dialog__bd').html('留言成功');
                    $('.weuilog').show();
                    $('.weui-dialog__ft').hide();
                    setTimeout(function(){
                        $('.weui-dialog__ft').show();
                        $('.weuilog').hide();
                    },1200);
                }
            },'json');
        });
    })

    $('.weuilog').click(function () {
        $('.weuilog').hide();
    })
</script>
</body>
</html>